#define  _CRT_SECURE_NO_WARNINGS



#include<stdio.h>
#include<string.h>


int fun(int n)
{
	int x = 0, y = 1;
	while (n)
	{
		x = n % 10;
		if (x != 0)
			y *= x;
		n /= 10;
	}
	return y;
}
int fun2(int n)
{
	int sum = 0;
	while (n)
	{
		sum++;
		n /= 10;
	}
	return sum;
}
int main()
{
	int n = 0;
	scanf("%d", &n);
	while (fun2(n) != 1)
	{
		n = fun(n);
	}
	printf("%d\n", n);
	return 0;
}